Skip to content

Conversation

@zyw-bot
Copy link
Collaborator

@zyw-bot zyw-bot commented Aug 24, 2025

Link: llvm/llvm-project#155087
Requested by: @andjo403

@github-actions github-actions bot mentioned this pull request Aug 24, 2025
@zyw-bot
Copy link
Collaborator Author

zyw-bot commented Aug 24, 2025

Diff mode

runner: ariselab-64c-docker
baseline: llvm/llvm-project@a7a1781
patch: llvm/llvm-project#155087
sha256: 44c956d672159e8c3843065441657583619dacbd8529e62b0b0893e67998ee5e
commit: 2fe341a

57 files changed, 67746 insertions(+), 67722 deletions(-)

Improvements:
  instcombine.NumExpand 2870 -> 2910 +1.39%
  correlated-value-propagation.NumAddNSW 271856 -> 271888 +0.01%
  instsimplify.NumSimplified 2539830 -> 2540019 +0.01%
  correlated-value-propagation.NumAddNW 500828 -> 500860 +0.01%
  simplifycfg.NumFoldBranchToCommonDest 772820 -> 772866 +0.01%
  correlated-value-propagation.NumNSW 632033 -> 632065 +0.01%
  gvn.NumGVNSimpl 4584424 -> 4584637 +0.00%
  correlated-value-propagation.NumDeadCases 68984 -> 68987 +0.00%
  correlated-value-propagation.NumNW 1039533 -> 1039565 +0.00%
  jump-threading.NumDupes 139281 -> 139284 +0.00%
Regressions:
  bdce.NumSimplified 6004 -> 6000 -0.07%
  correlated-value-propagation.NumAnd 46630 -> 46624 -0.01%
  correlated-value-propagation.NumCmps 292345 -> 292337 -0.00%
  bdce.NumRemoved 386558 -> 386554 -0.00%
  gvn.NumGVNInstr 155772 -> 155771 -0.00%
  gvn.NumGVNPRE 155772 -> 155771 -0.00%
  instcombine.NumSunkInst 3487296 -> 3487277 -0.00%
  licm.NumSunk 276742 -> 276741 -0.00%
  simplifycfg.NumHoistCommonInstrs 2421924 -> 2421916 -0.00%
  simplifycfg.NumHoistCommonCode 832886 -> 832884 -0.00%

9 10 bench/coreutils-rs/optimized/1rc3oz70a7y5cjew.ll
23 24 bench/coreutils-rs/optimized/26a2uyrtdxle93un.ll
56 56 bench/coreutils-rs/optimized/czge978gjagq0cc.ll
3 3 bench/meilisearch-rs/optimized/1cgo24wrkn2cjv53.ll
6 6 bench/pingora-rs/optimized/65aikiwd6g1bk45ph071o79dv.ll
42 46 bench/pingora-rs/optimized/6wibsd5gc0z7di4fjkaikq290.ll
7 9 bench/pola-rs/optimized/22hf7jzzgevg13mpf1ydyrfxa.ll
8 10 bench/pola-rs/optimized/27hqyqjqdjf2gpnz37f4yi4lt.ll
4 5 bench/pola-rs/optimized/38ypuj8xmaq1880ov8i7r4epo.ll
84 88 bench/pola-rs/optimized/4h98aq07mwhgxxkngeaedo5d3.ll
3 4 bench/pola-rs/optimized/9q9n1s2mf6dwmafgbo3deymin.ll
20 22 bench/pola-rs/optimized/dt45zdhwsb68fi1n587asph3s.ll
14 15 bench/pola-rs/optimized/dyvzogkr4de6dykkhg9ts44xu.ll
4 5 bench/pola-rs/optimized/e5h141x44lxp1jgda4wn9g2mb.ll
9 10 bench/quiche-rs/optimized/2gvjct5jtde9m3f5c2wx76gb9.ll
9 10 bench/quiche-rs/optimized/52nxvgz8yoonp9w4jarabvals.ll
38 34 bench/quinn-rs/optimized/aa0f6okxl6jzwxndw38ja55fd.ll
20 21 bench/regex-rs/optimized/183h9dropc9vohym.ll
3 4 bench/ruff-rs/optimized/1kimys0lkti8cuaap5m9le4oi.ll
8 9 bench/ruff-rs/optimized/3dfok8d8aknyc1byq695kiju1.ll
9 10 bench/ruff-rs/optimized/4indqiempoi7irtp7z9d7luyj.ll
32 35 bench/ruff-rs/optimized/76riqt46vtynf4kgizavl3q88.ll
20 21 bench/ruff-rs/optimized/9kdq8p9vbvp469l9m5kewm2r5.ll
3 4 bench/ruff-rs/optimized/bl7upda05f9py2dly725522mg.ll
8 9 bench/ruff-rs/optimized/cf4d78dtw2y7jldih6lhmy5k5.ll
12 13 bench/rust-analyzer-rs/optimized/1cf75p1eybr0uy0c.ll
12 13 bench/rust-analyzer-rs/optimized/3j0nbdwupb3iwt86.ll
9 10 bench/rust-analyzer-rs/optimized/ii5fl5y94ca5wd9.ll
33 34 bench/tokio-rs/optimized/46apu3hqx0w07xoc.ll
171 187 bench/typst-rs/optimized/2i78fvbm4wocuesi.ll
41 43 bench/typst-rs/optimized/3kgmqnxcsl3z3n0n.ll
9 11 bench/typst-rs/optimized/4qskctz4kwc33g7b.ll
58 59 bench/zed-rs/optimized/11rrvqb0alhs5mh4wxxke3etr.ll
11 12 bench/zed-rs/optimized/2ojzflncem0fdggrmkj3zmz27.ll

@github-actions
Copy link
Contributor

The provided patch consists of several changes across multiple Rust-based projects, primarily focused on optimizing conditional checks involving i8 values. Here are the major changes:

  1. Optimization of Equality and Truncation Patterns: In multiple functions, patterns that check if an i8 value is equal to 2 and then truncate it to an i1 are replaced with a more efficient sequence. Instead of using icmp eq i8 %val, 2 followed by trunc i8 %val to i1, the code now uses add nsw i8 %val, -1 followed by icmp ult i8 %.off, 2. This reduces the number of instructions and leverages unsigned comparison for better performance.

  2. Simplification of PHI Nodes: Several PHI nodes in the control flow graph are simplified or restructured to reflect the new branching logic. This includes updating the incoming values and labels to match the new control flow paths introduced by the optimized conditional checks.

  3. Branch Target Updates: Branch instructions are updated to point to new labels that reflect the optimized control flow. For example, br i1 %.0.not, label %14, label %36 is changed to br i1 %switch, label %12, label %34, indicating a shift in the control flow structure due to the optimization.

  4. Phi Node Label Adjustments: PHI nodes that aggregate values from different control flow paths are updated to reference the new labels. For instance, %.sroa.3.0 = phi ptr [ %56, %55 ], [ undef, %14 ], [ undef, %28 ], [ undef, %35 ] is changed to %.sroa.3.0 = phi ptr [ %56, %53 ], [ undef, %12 ], [ undef, %26 ], [ undef, %33 ], reflecting the new control flow labels.

  5. Consistency in PHI Node Updates: Across various functions, similar patterns of PHI node updates are applied consistently. This ensures that the optimized control flow is correctly reflected in the SSA (Static Single Assignment) form, maintaining the integrity of the program's logic while improving performance.

These changes collectively aim to enhance the performance of the code by reducing the number of instructions and simplifying the control flow, which can lead to better optimization opportunities for the compiler.

model: qwen-plus-latest
CompletionUsage(completion_tokens=499, prompt_tokens=113012, total_tokens=113511, completion_tokens_details=None, prompt_tokens_details=None)

@andjo403
Copy link

andjo403 commented Aug 24, 2025

when I run locally I fund the following regressions do not know why I can not see them here:

define i1 @src(i8 %x) {
  %and = and i8 %x, 1
  %add = add nsw i8 %and, -1
  %ret = icmp ult i8 %add, 2
  ret i1 %ret
}

define i1 @tgt(i8 %x) {
  %ret = trunc i8 %x to i1
  ret i1 %ret
}

https://alive2.llvm.org/ce/z/CBYHXA

some times with removed and replacing trunc nuw

was in
bench/pola-rs/optimized/91ojamjedp83lpe0pc0cw0okj.ll
bench/pola-rs/optimized/9kt0ps7am1ervf5eo1u53zq54.ll
bench/pola-rs/optimized/dbu7mtic1sqhs4ep0q5dcusid.ll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants